#!/usr/bin/env python

#    Copyright 2011,2012 Erik Persson
#
#    This file is part of the cell-sync-usrp project.
#
#    cell-sync-usrp is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    cell-sync-usrp is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with cell-sync-usrp.  If not, see <http://www.gnu.org/licenses/>.


""" Calculates the 2nd interleaving mapping for pccpch"""

m1 = [0,1*30, 2*30, 3*30, 4*30, 5*30, 6*30, 7*30, 8*30]
m2 = [0,20,10,5,15,25,3,13,23,8,18,28,1,11,21,6,16,26,4,14,24,19,9,29,12,2,7,22,27,17]

mapping = []
i = 0

for a in m2:
    for b in m1:
        mapping.append(a+b)

# remove empty mapped positions >= 135
i = len(mapping)-1
while (i>-1):
    if (mapping[i] >= 270):
        mapping.pop(i)
    i-=1
        
print "Mapping: " + str(mapping)
print "len of mapping: " + str(len(mapping))


""" Calculate the 1nd interleaving mapping for pccpch """

mapping2 = []
i=0
while (i<270):
    mapping2.append(i*2)
    i+=1
i=0
while (i<270):
    mapping2.append(i*2+1)
    i+=1

print "Mapping2: " + str(mapping2)
print "len of mapping 2: " +str(len(mapping2))
